home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: news.sfasu.edu!not-for-mail
- From: Sanjay Prabhakaran <sanjayp%hp9000@pcsbom.patni.com>
- Subject: Re: Allocating memory in windows programs
- Message-ID: <3177cc$5530.2e@news.sfasu.edu>
- Date: Sat, 23 Mar 1996 11:05:48 GMT
-
- dwnw%mimi@magic.itg.ti.com (Doug Nintzel) writes:
- > Hello, I am new at windows programming. I am using MS-SDK/c++. I am using the
- > below code to allocate memory....
- > /****************************************************************************/
- > memtst()
- > {
- > char FAR*str;
- > i=0;
- >
- > /*
- > if((str=(char*)malloc(sizev))==NULL){MessageBox(hWnd,"GlobLock()failed","globl
- > ock",MB_OK);return(0);}
- > for(i=0;i<555;++i)str[i]='x';str[25]='\0';
- > */
- > if((hmem=GlobalAlloc(GHND,100))==NULL){MessageBox(hWnd,"GlobAlloc(),
- > failed",MB_OK);return(0);}
- > str=(char FAR*)GlobalLock(hmem);
- > if(str==NULL){MessageBox(hWnd,"GlobLock()failed","globlock",MB_OK);return(0);}
- > MessageBox(hWnd,str,"ALLOC/LOCK OK",MB_OK);
- > strcpy(str,"mem test ok");
- > MessageBox(hWnd,str,"str content",MB_OK);
- > }
- > /****************************************************************************/
- > ...it crashes at strcpy(str,"mem test ok");...
- >
- > I have also tried to used the commented out malloc() test instead of
- > GlobalAlloc().
- > I have tried several other changes/combinations w/no luck.
- > I have also checked c++ FAQ's and checked several book stores.
- > I am running out of ideas!!!...Please help.....
- >
- > Thanks, Doug
- >
- >
-
-
- Hi,
- Even I'am new to windows programming.
- anyway are U using MSVCRT10.DLL
- I think all the standard C functions are present in that
- so it could be the problem
-
- Bye
- sanjayp%hp9000@pcsbom.patni.com
- Sanjay Prabhakaran
-
-
-
-
-